# Maintainer: Andrew Sun <adsun701@gmail.com>

_realname=libao
pkgbase=mingw-w64-${_realname}
pkgname=("${MINGW_PACKAGE_PREFIX}-${_realname}")
pkgver=1.2.2
pkgrel=2
pkgdesc="Cross-platform audio output library and plugins (mingw-w64)"
arch=('any')
mingw_arch=('mingw32' 'mingw64' 'ucrt64' 'clang64' 'clangarm64')
url="https://xiph.org/ao/"
msys2_references=(
  "cpe: cpe:/a:xiph:libao"
)
depends=("${MINGW_PACKAGE_PREFIX}-gcc-libs")
makedepends=("${MINGW_PACKAGE_PREFIX}-cc" "git" "${MINGW_PACKAGE_PREFIX}-autotools")
license=('GPL')
source=("https://gitlab.xiph.org/xiph/libao/-/archive/${pkgver}/${_realname}-${pkgver}.tar.gz")
sha256sums=('df8a6d0e238feeccb26a783e778716fb41a801536fe7b6fce068e313c0e2bf4d')

prepare() {
  cd "${srcdir}/${_realname}-${pkgver}"
  ./autogen.sh
}

build() {
  mkdir -p "${srcdir}/build-${MSYSTEM}" && cd "${srcdir}/build-${MSYSTEM}"

  LIBS+="-lksuser" \
  ../${_realname}-${pkgver}/configure \
    --prefix=${MINGW_PREFIX} \
    --build=${MINGW_CHOST} \
    --host=${MINGW_CHOST} \
    --target=${MINGW_CHOST} \
    --enable-static \
    --enable-shared \
    --disable-pulse \
    --enable-wmm

  make
}

package() {
  cd "${srcdir}/build-${MSYSTEM}"
  DESTDIR="${pkgdir}" make install

  install -Dm644 "${srcdir}/${_realname}-${pkgver}/COPYING" "${pkgdir}${MINGW_PREFIX}/share/licenses/${_realname}/COPYING"
}
